Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
@types/wrap-ansi
Advanced tools
TypeScript definitions for wrap-ansi
@types/wrap-ansi provides TypeScript type definitions for the wrap-ansi package, which is used to wrap words to a specified width while preserving ANSI escape codes.
Wrap text to a specified width
This feature allows you to wrap a string of text to a specified width. In this example, the input string is wrapped to a width of 20 characters.
const wrapAnsi = require('wrap-ansi');
const input = 'The quick brown fox jumps over the lazy dog';
const output = wrapAnsi(input, 20);
console.log(output);
Preserve ANSI escape codes
This feature ensures that ANSI escape codes are preserved when wrapping text. In this example, the input string contains ANSI escape codes for red text, and these codes are preserved in the output.
const wrapAnsi = require('wrap-ansi');
const input = '\u001B[31mThe quick brown fox jumps over the lazy dog\u001B[39m';
const output = wrapAnsi(input, 20);
console.log(output);
Hard wrapping
This feature allows for hard wrapping, which means that words will be split if they exceed the specified width. In this example, the input string is hard-wrapped to a width of 20 characters.
const wrapAnsi = require('wrap-ansi');
const input = 'The quick brown fox jumps over the lazy dog';
const output = wrapAnsi(input, 20, { hard: true });
console.log(output);
The word-wrap package provides similar functionality for wrapping text to a specified width, but it does not handle ANSI escape codes. It is simpler and more lightweight compared to wrap-ansi.
The cli-width package is used to get the width of the terminal, which can be useful in conjunction with wrap-ansi for dynamically wrapping text based on the terminal width. It does not provide text wrapping functionality by itself.
The slice-ansi package is used to slice a string containing ANSI escape codes without breaking the codes. It can be used in combination with other text-wrapping libraries to handle ANSI escape codes properly.
npm install --save @types/wrap-ansi
This package contains type definitions for wrap-ansi (https://www.npmjs.com/package/wrap-ansi).
Files were exported from https://www.github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/wrap-ansi
Additional Details
These definitions were written by Klaus Reimer https://github.com/kayahr.
FAQs
Stub TypeScript definitions entry for wrap-ansi, which provides its own types definitions
The npm package @types/wrap-ansi receives a total of 2,820,184 weekly downloads. As such, @types/wrap-ansi popularity was classified as popular.
We found that @types/wrap-ansi demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.